package com.tang.designpattern.singleton;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/4/30 17:51
 * 饿汉式单例
 */
public class SingletonDemo01 {
    //1.私有化构造器
    private  SingletonDemo01(){
    }
    //类初始化的时候，立即加载该对象
    private static SingletonDemo01 instance = new SingletonDemo01();

    //提供获取该对象的方法，没有synchronized，效率高
    public static SingletonDemo01 getInstance(){
        return instance;
    }
}
